from django.db import models
from shortuuidfield import ShortUUIDField





from users.models import TeacherModel

# 课程期数表
class NperModel(models.Model):
    id = ShortUUIDField(primary_key=True, verbose_name="课程限制id")
    number = models.CharField(max_length=255, verbose_name="学习人数")
    apply = models.CharField(max_length=255, verbose_name="报名人数")
    residue = models.CharField(max_length=255, verbose_name="剩余人数")
    apply_start_time = models.DateField(auto_now=False, verbose_name="报名开始时间")
    apply_end_time = models.DateField(auto_now=False, verbose_name="报名结束时间")
    start_time = models.DateField(auto_now=False, verbose_name="开始学习时间")
    end_time = models.DateField(auto_now=False, verbose_name="结束学习时间")
    learning = models.CharField(max_length=255, verbose_name="学习时长")

    class Meta:
        db_table = 'nper'
        verbose_name = '课程期数表'
        verbose_name_plural = verbose_name


# 课程分类表
class ClassificationCourseModel(models.Model):
    id = ShortUUIDField(primary_key=True, verbose_name="课程分类id")
    name = models.CharField(max_length=32, verbose_name="分类名称")
    class Meta:
        db_table = 'classification'
        verbose_name = '课程分类表'
        verbose_name_plural = verbose_name

# 课程表
class CourseModel(models.Model):
    GENDER_CHOICES = (
        (u'0', u'免费'),
        (u'1', u'付费'),
    )
    id = ShortUUIDField(primary_key=True, verbose_name="课程id")
    name = models.CharField(max_length=32, verbose_name="课程名称")
    introduce = models.CharField(max_length=255, verbose_name="课程介绍")
    money = models.CharField(max_length=32, verbose_name="课程费用")
    image = models.ImageField(verbose_name="上传图片", upload_to="static/course", blank=True)
    nper = models.ForeignKey(NperModel, on_delete=models.CASCADE)
    teacher = models.ForeignKey(to=TeacherModel, on_delete=models.CASCADE)
    classification = models.ForeignKey(to=ClassificationCourseModel,on_delete=models.CASCADE)
    status = models.CharField(max_length=2, choices=GENDER_CHOICES, default='0', verbose_name="是否")
    class Meta:
        db_table = 'course'
        verbose_name = '课程表'
        verbose_name_plural = verbose_name


# 轮播图
class ShufflingModel(models.Model):
    GENDER_CHOICES = (
        (u'0', u'显示'),
        (u'1', u'不显示'),
    )
    id = ShortUUIDField(primary_key=True, verbose_name="轮播图id")
    image = models.ImageField(verbose_name="上传图片", upload_to="static/course", blank=True)
    status = models.CharField(max_length=2, choices=GENDER_CHOICES, default='0', verbose_name="是否")
    class Meta:
        db_table = 'shuffling'
        verbose_name = '轮播图'
        verbose_name_plural = verbose_name


